home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!usenet
- From: tkg@lanl.gov (Thomas K. Gamble)
- Newsgroups: comp.lang.c,comp.lang.c++
- Subject: Re: Pascal 'real' to C 'float'
- Date: 25 Jan 1996 14:46:05 GMT
- Organization: Los Alamos National Lab.
- Distribution: world
- Message-ID: <4e853d$iqb@newshost.lanl.gov>
- NNTP-Posting-Host: gamble.lanl.gov
- X-Newsreader: NeoLogic News for OS/2 [version: 4.2]
-
- In message <4e674d$ett@maestro.netinc.ca> - swallace@netinc.ca (Shawn Wallace)
- writes:
- >
- >I've run into a little difficulty converting the data from an older
- >Pascal program into C.
- >
- >I need to convert the pascal 'real' number (which I believe to be a
- >6-byte struct) to a C/C++ float or double (which are 4 and 8-bytes
- >respecively).
- >
- >I seem to remember the Turbo Pascal help files describing the exact
- >way a pascal 'real' is stored, but I no longer have that compiler.
- >Could anyone shed any light on this? Please cc: any replies to my
- >email (just in case).
- >
- >Shawn
- >swallace@netinc.ca
- >
- >
-
- "Complete Turbo Pascal," by Jeff Duntemann, desribes 6 byte reals
- as follows.
-
- byte# 0 1 2 3 4 5
- exp lsb (mantissa) msb
-
-
- "From low memory to high: The exponent is stored in the first byte,
- followed by the least significant byte of the mantissa, the next most
- significant byte, and so on, for five bytes of mantissa.
- Forty-bits-worth of mantissa will give you eleven significant
- figures. Beyond that point, additional precition will be lost,
- although the exponent will always give you the correct order of
- magnitude to the limits of the range of type REAL."
-
-
- Hope this helps.
-
- ********************************************************************************
- Thomas K. Gamble tkg@lanl.gov, gamble@ibm.net
- member - TeamOS/2
-
- "Club Windows? I know a lot of people who would love to, and I suspect that not
- even environmentalists would protest." - Nicholas Petreley (InfoWorld 12/4/95)
- ********************************************************************************
-
-